package com.tfswx.jcyw.sqlmodel.api.bean.table;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author 张述江
 * @date 2023/9/15
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ParenthesedSelect extends Select implements FromItem {
    private Select select;

    public ParenthesedSelect(Select select) {
        this.select = select;
    }

    public ParenthesedSelect() {
        this(null);
    }

    @Override
    public StringBuilder appendSelectBodyTo(StringBuilder builder) {
        builder.append("(").append(select).append(")");
        if (select.getAlias() != null) {
            builder.append(select.getAlias());
        }
        return builder;
    }

    @Override
    public String toString() {
        return super.toString();
    }

}
